// pages/delivery/delivery.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
            c1:"",

        Title:[
            {
                id:0,
                name:"我的接单",
                isActive:true
            },
            {
                id:1, 
                name:"我的下单",
                isActive:false
            },
    
        ],

        // List:[
        //     {
        //         id:0,
        //         name:"起点",
        //     },
        //     {
        //         id:1,
        //         name:"终点"
        //     },
        //     {
        //         id:2,
        //         name:"订单状态"
        //     }
        // ],

        consumer:[
            
        ],

        sever:[
        ],





    },







    //改变显示内容及标题状态
    handItemchange(e){
        const {index}=e.currentTarget.dataset;
        let {Title}=this.data;
        Title.forEach((v,i)=>i===index?v.isActive=true:v.isActive=false);
        this.setData({
            Title
        })
    },

        //跳转到我的下单的订单详情
        navigatoOrderDetail:function(e){

            wx.showModal({
              title:"订单详情",
              content:"进入订单详情",
              success(res){
                  if(res.confirm){
                      console.log(e.currentTarget.id) 
                    wx.navigateTo({
                        url: '/pages/orderDetail/orderDetail?openid= '+ JSON.stringify(e.currentTarget.id)
                      })
                  }
                  else if (res.cancel)
                  {
                      console.log('取消')
                  }
              },
              
            })

        }, 




    //通过token来获取我的约车接单列表和我的约车下单列表
    onLoad: function () {
        var that =this
        that.setData({
            token:wx.getStorageSync({key:'token', success(){console.log("读取用户token失败")}})
        })



         


        wx.request({
            url: 'http://119.23.252.15:10002/car/myOrders',
            method:"POST",
            data:{
        token:wx.getStorageSync('token')
            },
            success(res){
                console.log("获取我的约车订单")
                console.log(wx.getStorageSync('token'))
                that.setData({
                    consumer:res.data.data.myServe,
                    sever:res.data.data.myConsumption
                })
            }
          })



    },



})